package hashtable;


/**
 * @ author : HyoJoo-W
 * @ createDate : 2021-06-04 14:34
 * @ Description :
 */
public class EmpLinkedList
{
    public Emp head = null;

    public void add(Emp emp)
    {
        if (head == null)
        {
            head = emp;
            return;
        }
        Emp cur = head;
        while (cur.next != null)
        {
            cur = cur.next;
        }

        cur.next = emp;
    }

    public void list(int no)
    {
        if (head == null)
        {
            System.out.println("第" + (no + 1) + "条链表为空");
            return;
        }
        Emp cur = head;
        System.out.print("第" + (no + 1) + "条链表 =>");
        while (true)
        {
            System.out.print(cur + "=>");
            if (cur.next == null)
            {
                break;
            }
            cur = cur.next;
        }
        System.out.println();
    }

    public Emp findEmpById(int id)
    {
        if (head == null)
        {
            System.out.println("链表为空");
            return null;
        }
        Emp cur = head;
        while (true)
        {
            if (cur.id == id)
            {
                break;
            }
            if (cur.next == null)
            {
                cur = null;
                break;
            }
            cur = cur.next;
        }
        return cur;
    }

}
